package sistemasdistribuidos;

import classesBase.ModelaTabela;
import com.sun.imageio.plugins.jpeg.JPEG;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.text.SimpleDateFormat;
import java.util.Date;
import telasMensagem.bloqueio;

public class agendaBanhoTosa extends javax.swing.JDialog {

    ModelaTabela modela = new ModelaTabela();
    byte parImpar = 0;
    Date data = new Date();
    SimpleDateFormat formata = new SimpleDateFormat("dd/MM/yyyy");
    String date = formata.format(data);
    static byte flag = 1;

    public agendaBanhoTosa(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        jFormattedDataAgenda.setText(date);
        tabela();
        jButtonBuscarAnimal.setEnabled(false);
        jButtonBuscarDono.setEnabled(false);
        jTextFieldAnimal.setEditable(false);
        jTextFieldCodigo.setEditable(false);
        jTextFieldDono.setEditable(false);
        jTextPaneObservacoes.setEditable(false);
        jComboBoxHora.setEnabled(false);

        addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                if (flag == 0) {
                    bloqueio sn = new bloqueio(null, true, "<html>Por favor, salve "
                            + "os dados editados antes de deixar esta tela!<html>");
                    sn.setLocationRelativeTo(null);
                    sn.setVisible(true);
                } else {
                    dispose();
                }
            }
        });
    }

    public void tabela() {
        modela.setColumnIdentifiers(new String[]{"Horário", "Código", "Reserva"});
        for (int j = 9; j < 19; j++) {
            //0 = par 1 = impar
            if (parImpar == 0) {
                if (j > 12) {
                    modela.addRow(new String[]{j + ":00 pm", "", ""});
                    jComboBoxHora.addItem(j + ":00 pm");
                } else {
                    modela.addRow(new String[]{j + ":00 am", "", ""});
                    jComboBoxHora.addItem(j + ":00 am");
                }
                j--;
                parImpar = 1;
            } else {
                if (j > 12) {
                    modela.addRow(new String[]{j + ":30 pm", "", ""});
                    jComboBoxHora.addItem(j + ":30 pm");
                } else {
                    modela.addRow(new String[]{j + ":30 am", "123", ""});
                    jComboBoxHora.addItem(j + ":30 am");
                }
                parImpar = 0;
            }
        }
        jTableAgenda.setModel(modela);

        if (jComboBoxProfissional.getSelectedIndex() > 0) {
            /*Pegar agendamentos e colocar na tabela*/
            //teste
            // modela.se
        }
    }

    public boolean data() {
        String[] div = jFormattedDataAgenda.getText().split("/");
        if (Integer.parseInt(div[1]) == 02 && Integer.parseInt(div[0]) > 28) {
            bloqueio bl = new bloqueio(null, true, "<html>O mês de Fevereiro não possui o dia "
                    + "indicado. </br> Por favor, verifique a data do agendamento"
                    + " antes de prosseguir!<html>");
            bl.setLocationRelativeTo(null);
            bl.setVisible(true);
            return false;
        } else {
            if (Integer.parseInt(div[1]) == 04
                    | Integer.parseInt(div[1]) == 06
                    | Integer.parseInt(div[1]) == 9
                    | Integer.parseInt(div[1]) == 11
                    && Integer.parseInt(div[0]) > 30) {
                System.out.println(div[1] + div[0]);
                bloqueio bl = new bloqueio(null, true, "<html>O mês escolhido não possui o dia "
                        + "indicado. </br> Por favor, verifique a data do agendamento"
                        + " antes de prosseguir!</html>");
                bl.setLocationRelativeTo(null);
                bl.setVisible(true);
                return false;
            } else {
                if (Integer.parseInt(div[0]) > 31
                        || Integer.parseInt(div[1]) > 12
                        || Integer.parseInt(div[2]) < 2014) {
                    bloqueio bl = new bloqueio(null, true, "<html>Por favor, coloque uma"
                            + " data válida para incluir/editar um novo agendamento!</html>");
                    bl.setLocationRelativeTo(null);
                    bl.setVisible(true);
                    return false;
                } else {
                    return true;
                }
            }
        }
    }
    
    public static void informacoes(String nomeA, String nomeD, int codA, int codD){
        jTextFieldAnimal.setText(nomeA);
        jTextFieldDono.setText(nomeD);
        //trocar o nome pelo ID do animal 
        // e do dono, depois buscar no banco e joga na tela
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabelMsg10 = new javax.swing.JLabel();
        jLabelMsg14 = new javax.swing.JLabel();
        jButtonIncluir = new javax.swing.JButton();
        jButtonDeletarAgendamentos = new javax.swing.JButton();
        jLabelMsg11 = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTableAgenda = new javax.swing.JTable();
        jComboBoxProfissional = new javax.swing.JComboBox();
        jLabelMsg12 = new javax.swing.JLabel();
        jFormattedDataAgenda = new javax.swing.JFormattedTextField();
        jLabelMsg13 = new javax.swing.JLabel();
        jLabelMsg16 = new javax.swing.JLabel();
        jLabelMsg17 = new javax.swing.JLabel();
        jLabelMsg18 = new javax.swing.JLabel();
        jTextFieldAnimal = new javax.swing.JTextField();
        jTextFieldDono = new javax.swing.JTextField();
        jButtonBuscarAgenda = new javax.swing.JButton();
        jLabelMsg19 = new javax.swing.JLabel();
        jTextFieldCodigo = new javax.swing.JTextField();
        jScrollPane4 = new javax.swing.JScrollPane();
        jTableServiços = new javax.swing.JTable();
        jLabelMsg20 = new javax.swing.JLabel();
        jScrollPane6 = new javax.swing.JScrollPane();
        jTextPaneObservacoes = new javax.swing.JTextPane();
        jButtonEditar = new javax.swing.JButton();
        jButtonBuscarAnimal = new javax.swing.JButton();
        jButtonBuscarDono = new javax.swing.JButton();
        jComboBoxHora = new javax.swing.JComboBox();
        jButtonTransferir = new javax.swing.JButton();
        jButtonBuscarDono1 = new javax.swing.JButton();
        jButtonEditar1 = new javax.swing.JButton();
        jTextFieldCodigo1 = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Agenda Banho Tosa");

        jPanel1.setBackground(new java.awt.Color(255, 102, 0));
        jPanel1.setBorder(javax.swing.BorderFactory.createMatteBorder(3, 3, 3, 3, new java.awt.Color(0, 0, 0)));

        jLabelMsg10.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg10.setText("Data da Agenda:");

        jLabelMsg14.setFont(new java.awt.Font("Segoe UI", 1, 36)); // NOI18N
        jLabelMsg14.setText("Agenda de Banho e Tosa");

        jButtonIncluir.setBackground(new java.awt.Color(255, 255, 255));
        jButtonIncluir.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jButtonIncluir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/pata.png"))); // NOI18N
        jButtonIncluir.setText("Incluir ");
        jButtonIncluir.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonIncluir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonIncluirActionPerformed(evt);
            }
        });

        jButtonDeletarAgendamentos.setBackground(new java.awt.Color(255, 255, 255));
        jButtonDeletarAgendamentos.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jButtonDeletarAgendamentos.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/osso.png"))); // NOI18N
        jButtonDeletarAgendamentos.setText("Deletar Agendamento Selecionado");
        jButtonDeletarAgendamentos.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonDeletarAgendamentos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonDeletarAgendamentosActionPerformed(evt);
            }
        });

        jLabelMsg11.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg11.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/banho.png"))); // NOI18N

        jTableAgenda.setBorder(javax.swing.BorderFactory.createMatteBorder(2, 2, 2, 2, new java.awt.Color(0, 0, 0)));
        jTableAgenda.setFont(new java.awt.Font("Segoe UI", 0, 18)); // NOI18N
        jTableAgenda.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Horário", "Código", "Cachorro"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTableAgenda.setRowHeight(25);
        jScrollPane3.setViewportView(jTableAgenda);

        jComboBoxProfissional.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jComboBoxProfissional.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Selecione", "Teste" }));
        jComboBoxProfissional.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxProfissionalActionPerformed(evt);
            }
        });

        jLabelMsg12.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg12.setText("Profissional:");

        try {
            jFormattedDataAgenda.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jFormattedDataAgenda.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N

        jLabelMsg13.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg13.setText("Horário:");

        jLabelMsg16.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg16.setText("<html><u>Animal:</u></html>");
        jLabelMsg16.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabelMsg17MouseClicked(evt);
            }
        });

        jLabelMsg17.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg17.setText("<html><u>Dono:</html></u>");
        jLabelMsg17.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabelMsg17MouseClicked(evt);
            }
        });

        jLabelMsg18.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg18.setText("Serviços:");

        jTextFieldAnimal.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jTextFieldAnimal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldAnimalActionPerformed(evt);
            }
        });

        jTextFieldDono.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jTextFieldDono.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldDonoActionPerformed(evt);
            }
        });

        jButtonBuscarAgenda.setBackground(new java.awt.Color(255, 255, 255));
        jButtonBuscarAgenda.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jButtonBuscarAgenda.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/Busca_Icon.png"))); // NOI18N
        jButtonBuscarAgenda.setText("Pesquisar");
        jButtonBuscarAgenda.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonBuscarAgenda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonBuscarAgendaActionPerformed(evt);
            }
        });

        jLabelMsg19.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg19.setText("Código:");

        jTextFieldCodigo.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jTextFieldCodigo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldCodigoActionPerformed(evt);
            }
        });

        jTableServiços.setBorder(javax.swing.BorderFactory.createMatteBorder(2, 2, 2, 2, new java.awt.Color(0, 0, 0)));
        jTableServiços.setFont(new java.awt.Font("Segoe UI", 0, 18)); // NOI18N
        jTableServiços.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Código", "Horário", "Cachorro"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane4.setViewportView(jTableServiços);

        jLabelMsg20.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg20.setText("Observações:");

        jTextPaneObservacoes.setEditable(false);
        jTextPaneObservacoes.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jTextPaneObservacoes.setEnabled(false);
        jScrollPane6.setViewportView(jTextPaneObservacoes);

        jButtonEditar.setBackground(new java.awt.Color(255, 255, 255));
        jButtonEditar.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jButtonEditar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/pata.png"))); // NOI18N
        jButtonEditar.setText("Editar");
        jButtonEditar.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonEditar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonEditarActionPerformed(evt);
            }
        });

        jButtonBuscarAnimal.setBackground(new java.awt.Color(255, 255, 255));
        jButtonBuscarAnimal.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jButtonBuscarAnimal.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/Busca_Icon.png"))); // NOI18N
        jButtonBuscarAnimal.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonBuscarAnimal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonBuscarAnimalActionPerformed(evt);
            }
        });

        jButtonBuscarDono.setBackground(new java.awt.Color(255, 255, 255));
        jButtonBuscarDono.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jButtonBuscarDono.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/Busca_Icon.png"))); // NOI18N
        jButtonBuscarDono.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonBuscarDono.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonBuscarDonoActionPerformed(evt);
            }
        });

        jComboBoxHora.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jComboBoxHora.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Selecione" }));
        jComboBoxHora.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxHoraActionPerformed(evt);
            }
        });

        jButtonTransferir.setBackground(new java.awt.Color(255, 255, 255));
        jButtonTransferir.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jButtonTransferir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/pata.png"))); // NOI18N
        jButtonTransferir.setText("Transferir");
        jButtonTransferir.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonTransferir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonTransferirActionPerformed(evt);
            }
        });

        jButtonBuscarDono1.setBackground(new java.awt.Color(255, 255, 255));
        jButtonBuscarDono1.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jButtonBuscarDono1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/Busca_Icon.png"))); // NOI18N
        jButtonBuscarDono1.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonBuscarDono1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonBuscarDono1ActionPerformed(evt);
            }
        });

        jButtonEditar1.setBackground(new java.awt.Color(255, 255, 255));
        jButtonEditar1.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jButtonEditar1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/pata.png"))); // NOI18N
        jButtonEditar1.setText("Deletar Serviço");
        jButtonEditar1.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonEditar1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonEditar1ActionPerformed(evt);
            }
        });

        jTextFieldCodigo1.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jTextFieldCodigo1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldCodigo1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabelMsg12)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jComboBoxProfissional, javax.swing.GroupLayout.PREFERRED_SIZE, 209, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jButtonDeletarAgendamentos, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jButtonIncluir)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButtonEditar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButtonTransferir)))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(122, 122, 122)
                                .addComponent(jLabelMsg11, javax.swing.GroupLayout.PREFERRED_SIZE, 188, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(31, 31, 31)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(jLabelMsg10)
                                        .addGap(18, 18, 18)
                                        .addComponent(jFormattedDataAgenda, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jButtonBuscarAgenda))
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(jLabelMsg19)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jTextFieldCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(57, 57, 57)
                                        .addComponent(jLabelMsg13)
                                        .addGap(18, 18, 18)
                                        .addComponent(jComboBoxHora, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(32, 32, 32)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane4, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                            .addComponent(jScrollPane6, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabelMsg18)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextFieldCodigo1, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(10, 10, 10)
                                .addComponent(jButtonBuscarDono1, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jButtonEditar1))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabelMsg20)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabelMsg16, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jLabelMsg17, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addComponent(jTextFieldDono)
                                            .addComponent(jTextFieldAnimal, javax.swing.GroupLayout.PREFERRED_SIZE, 291, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jButtonBuscarAnimal, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jButtonBuscarDono, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))))
                                .addGap(0, 0, Short.MAX_VALUE)))))
                .addContainerGap())
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(175, 175, 175)
                .addComponent(jLabelMsg14)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addComponent(jLabelMsg14)
                .addGap(8, 8, 8)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jFormattedDataAgenda, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabelMsg10)
                        .addComponent(jButtonBuscarAgenda, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jComboBoxProfissional, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabelMsg12)))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 455, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jButtonIncluir, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButtonEditar, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButtonTransferir, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButtonDeletarAgendamentos, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(32, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(11, 11, 11)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jComboBoxHora, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabelMsg19)
                                .addComponent(jTextFieldCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabelMsg13)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabelMsg16, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jTextFieldAnimal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(18, 18, 18)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabelMsg17, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jTextFieldDono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jButtonBuscarAnimal, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(jButtonBuscarDono, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(11, 11, 11)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(7, 7, 7)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabelMsg18)
                                    .addComponent(jTextFieldCodigo1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addComponent(jButtonEditar1, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButtonBuscarDono1, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabelMsg20)
                        .addGap(1, 1, 1)
                        .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabelMsg11, javax.swing.GroupLayout.DEFAULT_SIZE, 181, Short.MAX_VALUE))))
        );

        jPanel1Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jButtonDeletarAgendamentos, jButtonIncluir});

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jComboBoxProfissionalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxProfissionalActionPerformed

    }//GEN-LAST:event_jComboBoxProfissionalActionPerformed

    private void jTextFieldAnimalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldAnimalActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextFieldAnimalActionPerformed

    private void jTextFieldDonoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldDonoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextFieldDonoActionPerformed

    private void jLabelMsg17MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelMsg17MouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_jLabelMsg17MouseClicked

    private void jTextFieldCodigoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldCodigoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextFieldCodigoActionPerformed

    private void jButtonBuscarAgendaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBuscarAgendaActionPerformed
        if (jComboBoxProfissional.getSelectedIndex() == 0) {
            bloqueio bl = new bloqueio(null, true, "<html>Por favor, selecione o profissional"
                    + " que deseja buscar os agendamentos marcados!</html>");
            bl.setLocationRelativeTo(null);
            bl.setVisible(true);
        } else {
            if (data() == true) {
                /*Trazer agenda do profissional e preencher a tabela*/
            }
        }
    }//GEN-LAST:event_jButtonBuscarAgendaActionPerformed

    private void jButtonDeletarAgendamentosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonDeletarAgendamentosActionPerformed

    }//GEN-LAST:event_jButtonDeletarAgendamentosActionPerformed

    private void jButtonIncluirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonIncluirActionPerformed
        if (jComboBoxProfissional.getSelectedIndex() == 0) {
            bloqueio bl = new bloqueio(null, true, "<html>Por favor, selecione o profissional"
                    + " que deseja incluir/editar um novo agendamento!</html>");
            bl.setLocationRelativeTo(null);
            bl.setVisible(true);
        } else {
            if (data() == true) {
                int linha = jTableAgenda.getSelectedRows().length;
                if (linha > 1) {
                    bloqueio bl = new bloqueio(null, true, "<html>Por favor, selecione "
                            + "apenas um horário para o agendamento!</html>");
                    bl.setLocationRelativeTo(null);
                    bl.setVisible(true);
                } else {
                    try {
                        linha = jTableAgenda.getSelectedRow();
                        incluirAgendamento ia = new incluirAgendamento(null, true,
                                jFormattedDataAgenda.getText(), (String) jTableAgenda.getValueAt(linha, 0),
                                (String) jComboBoxProfissional.getSelectedItem());
                        ia.setLocationRelativeTo(null);
                        ia.setVisible(true);
                        this.dispose();
                    } catch (Exception ex) {
                        bloqueio bl = new bloqueio(null, true, "<html>Por favor, selecione um "
                                + "horário para o agendamento!</html>");
                        bl.setLocationRelativeTo(null);
                        bl.setVisible(true);
                    }
                }

            }
        }
    }//GEN-LAST:event_jButtonIncluirActionPerformed

    private void jButtonEditarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonEditarActionPerformed
        int linha = jTableAgenda.getSelectedRows().length;
        if (linha > 1) {
            bloqueio b = new bloqueio(null, true, "<html>Por favor, selecione apenas "
                    + "um agendamento por vez!</html>");
            b.setLocationRelativeTo(null);
            b.setVisible(true);
        } else {
            if (linha == 0) {
                bloqueio b = new bloqueio(null, true, "<html>Por favor, selecione um dos "
                        + "agendamentos para prosseguir!</html>");
                b.setLocationRelativeTo(null);
                b.setVisible(true);
            } else {
                linha = jTableAgenda.getSelectedRow();
                if (jTableAgenda.getValueAt(linha, 1).equals("")) {
                    bloqueio b = new bloqueio(null, true, "<html>Não há agendamentos "
                            + "no horário selecionado! Por favor, selecione um agendamento "
                            + "preenchido!</html>");
                    b.setLocationRelativeTo(null);
                    b.setVisible(true);
                } else {
                    if (flag == 0) {
                        jButtonEditar.setText("Editar");
                        jButtonDeletarAgendamentos.setEnabled(true);
                        jButtonTransferir.setEnabled(true);
                        jButtonIncluir.setEnabled(true);
                        jFormattedDataAgenda.setEditable(true);
                        jButtonBuscarAgenda.setEnabled(true);
                        jComboBoxProfissional.setEnabled(true);
                        jButtonBuscarAnimal.setEnabled(true);
                        jButtonBuscarDono.setEnabled(false);
                        jTextFieldAnimal.setEditable(false);
                        jTextFieldCodigo.setEditable(false);
                        jTextFieldDono.setEditable(false);
                        jTextPaneObservacoes.setEditable(false);
                        jComboBoxHora.setEnabled(false);
                        flag = 1;
                    } else {
                        jButtonEditar.setText("Salvar");
                        jButtonDeletarAgendamentos.setEnabled(false);
                        jButtonTransferir.setEnabled(false);
                        jButtonIncluir.setEnabled(false);
                        jFormattedDataAgenda.setEditable(false);
                        jButtonBuscarAgenda.setEnabled(false);
                        jComboBoxProfissional.setEnabled(false);
                        jButtonBuscarAnimal.setEnabled(false);
                        jButtonBuscarDono.setEnabled(true);
                        jTextFieldAnimal.setEditable(true);
                        jTextFieldCodigo.setEditable(true);
                        jTextFieldDono.setEditable(true);
                        jTextPaneObservacoes.setEditable(true);
                        jComboBoxHora.setEnabled(true);
                        flag = 0;
                    }
                }
            }
        }
    }//GEN-LAST:event_jButtonEditarActionPerformed

    private void jButtonBuscarAnimalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBuscarAnimalActionPerformed
         try {
         animaisCadastrados a = new animaisCadastrados(null, true, 0);
         a.setLocationRelativeTo(null);
         a.setVisible(true);
         } catch (Exception ex) {
         System.out.println(ex);
         }
    }//GEN-LAST:event_jButtonBuscarAnimalActionPerformed

    private void jButtonBuscarDonoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBuscarDonoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButtonBuscarDonoActionPerformed

    private void jComboBoxHoraActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxHoraActionPerformed
        String hor = (String) jComboBoxHora.getSelectedItem();

        for (int i = 0; i < 20; i++) {
            if (hor.equals((String) jTableAgenda.getValueAt(i, 0))) {
                if (jTableAgenda.getValueAt(i, 1).toString().length() == 0) {
                    /*tirar da linha agendada e colocar na linha sem agendamento
                     mudar o horário no banco de dados*/
                } else {
                    bloqueio b = new bloqueio(null, true, "<html>Já há um agendamento neste horário! </br>"
                            + "Por favor, escolha um horário vago.</html>");
                    b.setLocationRelativeTo(null);
                    b.setVisible(true);
                }
            }
        }
    }//GEN-LAST:event_jComboBoxHoraActionPerformed

    private void jButtonTransferirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonTransferirActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButtonTransferirActionPerformed

    private void jButtonBuscarDono1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBuscarDono1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButtonBuscarDono1ActionPerformed

    private void jButtonEditar1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonEditar1ActionPerformed
     
    }//GEN-LAST:event_jButtonEditar1ActionPerformed

    private void jTextFieldCodigo1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldCodigo1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextFieldCodigo1ActionPerformed

    public static void main(String args[]) {
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;

                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(agendaBanhoTosa.class
                    .getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(agendaBanhoTosa.class
                    .getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(agendaBanhoTosa.class
                    .getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(agendaBanhoTosa.class
                    .getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                agendaBanhoTosa dialog = new agendaBanhoTosa(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonBuscarAgenda;
    private javax.swing.JButton jButtonBuscarAnimal;
    private javax.swing.JButton jButtonBuscarDono;
    private javax.swing.JButton jButtonBuscarDono1;
    private javax.swing.JButton jButtonDeletarAgendamentos;
    private javax.swing.JButton jButtonEditar;
    private javax.swing.JButton jButtonEditar1;
    private javax.swing.JButton jButtonIncluir;
    private javax.swing.JButton jButtonTransferir;
    public static javax.swing.JComboBox jComboBoxHora;
    public static javax.swing.JComboBox jComboBoxProfissional;
    public static javax.swing.JFormattedTextField jFormattedDataAgenda;
    private javax.swing.JLabel jLabelMsg10;
    private javax.swing.JLabel jLabelMsg11;
    private javax.swing.JLabel jLabelMsg12;
    private javax.swing.JLabel jLabelMsg13;
    private javax.swing.JLabel jLabelMsg14;
    private javax.swing.JLabel jLabelMsg16;
    private javax.swing.JLabel jLabelMsg17;
    private javax.swing.JLabel jLabelMsg18;
    private javax.swing.JLabel jLabelMsg19;
    private javax.swing.JLabel jLabelMsg20;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JTable jTableAgenda;
    private javax.swing.JTable jTableServiços;
    public static javax.swing.JTextField jTextFieldAnimal;
    public static javax.swing.JTextField jTextFieldCodigo;
    public static javax.swing.JTextField jTextFieldCodigo1;
    public static javax.swing.JTextField jTextFieldDono;
    public static javax.swing.JTextPane jTextPaneObservacoes;
    // End of variables declaration//GEN-END:variables
}
